package com.example.administrator.zhongyichou.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * 第三版新加
 * Created by lichenyu on 2017/6/28.
 */

public abstract class ListBaseAdapter<T> extends BaseAdapter {

    private List<T> list;
    private Context mContext;

    public ListBaseAdapter(Context mContext, List<T> list) {
        this.mContext = mContext;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list == null ? 0 : list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public abstract View getView(int position, View convertView, ViewGroup parent);


    public T getData(int position) {
        return list.get(position);
    }

    public List<T> getList(){
        return list;
    }

    public Context getContext() {
        return mContext;
    }

    public void setData(List<T> list) {
        this.list = list;
        notifyDataSetChanged();
    }
}
